<?php
$q or err('请输入关键词！');
$q = gbk($q);

$r = $db->get_one("SELECT COUNT(id) as count FROM ".DB_PRE."shop WHERE (shopname LIKE '%$q%' OR content LIKE '%$q%') AND `areacode` LIKE '$acode%' AND status = 1");
$num = $r['count'];

$pagesize = 20; 
$page = isset($page) && !empty($page) ? intval($page) : 1;
$offset = ($page-1)*$pagesize;

$pages = m_pages($num, $page, 'index.php?file='.$file.'&amp;q='.$q.$cityparam.'&amp;page=', $pagesize);
$r = $db->select("SELECT * FROM ".DB_PRE."shop WHERE (shopname LIKE '%$q%' OR content LIKE '%$q%') AND `areacode` LIKE '$acode%' AND status = 1 ORDER BY id DESC LIMIT $offset,$pagesize");
array2utf8($r);

$q = utf8($q);
include mtpl('search');
?>